using UnityEngine;
using System.Collections;

public class PlayerIdleState : State<PlayerControl>
{
    #region Singleton

    private static PlayerIdleState instance = new PlayerIdleState();
    public static PlayerIdleState Instance { get { return instance; } }
    private PlayerIdleState() { }

    #endregion

    #region State

    public override void OnEnterState(PlayerControl behaviour)
    {
        //behaviour.gameObject.renderer.material.color = Color.white;
    }

    public override void OnUpdateState(PlayerControl behaviour)
    {
        behaviour.Move(false, behaviour.walkSpeed, behaviour.groundGravityPercent);

        // Walk and Run
        if (Input.GetAxis(Constants.HORIZONTAL_AXIS) != 0)
        {
            if(Input.GetButton(Constants.RUN_BUTTON) && !behaviour.NoStamina)
                behaviour.State = PlayerRunState.Instance;
            else
                behaviour.State = PlayerWalkState.Instance;
        }

        //// Jump
        //if (Input.GetButtonDown(Constants.JUMP_BUTTON))
        //{
        //    behaviour.State = PlayerJumpState.Instance;
        //    return;
        //}

        // Attack
        else if (Input.GetButtonDown(Constants.ATTACK_BUTTON))
            behaviour.State = PlayerAttackState.Instance;

        //// Fall
        //if (!behaviour.characterController.isGrounded)
        //{
        //    behaviour.State = PlayerFallingState.Instance;
        //    return;
        //}        
    }

    public override void OnFixedUpdateState(PlayerControl behaviour)
    {

    }

    public override void OnExitState(PlayerControl behaviour)
    {

    }

    public override void OnCollisionState(PlayerControl behaviour, Collision other)
    {
    }

    public override void OnTriggerState(PlayerControl behaviour, Collider other)
    {
    }

    #endregion
}
